package ch06.home;

class Bread{
	String name;
	int price;	
	
	Bread() {}
	
	Bread(String name,int price){
		this.name = name;
		this.price = price;		
	}
}

class Baker{
	String name;
	
	Baker(){}
	
	Baker(String name){
		this.name = name;		
	}	
	
	void clean(){ 
		System.out.println("청소합니다.");
	}
	
	Bread bake(String name,int price){
		System.out.println (name + "을 만듭니다.");
		return new Bread(name,price);
	}
	
	void display(Bread[] shelf, Bread[] tray){
		System.arraycopy(tray,0, shelf, 0,tray.length);
	}
	
	int sell(Bread bread,int count){
		return bread.price * count;
	}
}

class Bakery{
	Bread[] shelf;
	Bread[] tray;
	Baker baker1;
	Baker baker2;
	
	Bakery(){
		this.shelf = new Bread[5];
		this.tray = new Bread[5];		
	}
	
	void open(){
		System.out.println("가게 문을 열었습니다.");
		
		baker1 = new Baker("최한석");
		baker2 = new Baker("김나리");
		
		baker1.clean();			
		
		String[] breadName = {"단팥빵","소보루","크림빵","초코빵","카스테라"};
		int[] price = {1000,1500,2000,2000,3000};
		
		for(int i=0;i<tray.length;i++)
			tray[i] = baker1.bake(breadName[i],price[i]);	
		
		baker2.display(shelf, tray);
		
		System.out.println(
				shelf[0].name+"을 "+ baker2.sell(shelf[0], 10)+"어치 팔았습니다.");
	}
	
	void close(){
		System.out.println("가게 문을 닫습니다.");
	}
	
}

public class BakeryTest {
	public static void main(String[] args){
		Bakery bakery = new Bakery();
		bakery.open();
		bakery.close();
	}
}
